package org.ix.gateway.controller;

import org.ix.gateway.client.RoutesClient;
import org.ix.gateway.client.model.GatewayRouteResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RouteController {

    @Autowired
    RoutesClient routesClient;

    /**
     * 获取路由版本
     *
     * @return 路由版本
     */
    @GetMapping("/get-last-version")
    public Long getRoutesVersion() throws Exception {
        return routesClient.getRoutesVersion();
    }

    /**
     * 获取路由
     *
     * @return 路由列表
     */
    @GetMapping("/list")
    public List<GatewayRouteResponse> getRoutes() throws Exception {
        return routesClient.getRoutes();
    }
}
